<%--
  Created by IntelliJ IDEA.
  User: 27236
  Date: 2021/8/23
  Time: 18:20
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>诚信考试</title>
    <link href="${pageContext.request.contextPath}/static/css/bootstrap.min.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/static/js/jquery-3.6.0.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/bootstrap.min.js"></script>

</head>
<body>
<form id="frm" action="http://www.baidu.com">
    考试还剩余<div id="time"></div>
</form>
<script>
    var times = ${time};//剩余时间,单位秒
    var time = time/1000;
    var timeDiv = document.getElementById("time");
    var timeObj = null;
    function timer(){
        if(time == 0){
            //倒计时结束，提交表单
            document.getElementById("frm").submit();
            window.clearInterval(timeObj);
            return;
        }
        var t = Math.floor(time/60) +"分"+time%60+"秒"
        timeDiv.innerHTML = t;
        time --;
    }
    timeObj = window.setInterval(timer,1000);
</script>
</body>
</html>
